<template>
  <div class="container insurance-agent">
    <div class="top-box">
      <el-card class="card my-info">
        <div class="banner-box">
          <div class="title-box">
            <div class="title">广东电信住院医疗险</div>
            <div class="tip">能<span class="red">保一辈子</span>的医疗险</div>
          </div>
          <div class="number-box">
            <div class="number1">报销额度 <span class="red">600万</span></div>
            <div class="number2">
              <div class="icon" />保险热销总榜第一
            </div>
          </div>
        </div>
        <div class="info-box">
          <div class="info-item my-base">
            <div class="avatar" />
            <div class="title">张三 男</div>
            <div class="link">已有保单 {{ 2 }}></div>
          </div>
          <div class="info-item my-claims">
            <div class="title">我的理赔</div>
            <div class="link">在线理赔测算></div>
          </div>
          <div class="info-item my-info">
            <div class="title"></div>
            <div class="link">完善信息></div>
          </div>
        </div>
      </el-card>
      <el-card class="card insurance-selected">
        <div class="left-box">
          <div class="insurance-item">
            <div class="text-box">
              <div class="label">住院险</div>
              <div class="value">未保障</div>
            </div>
            <div class="icon" />
          </div>
          <div class="insurance-item">
            <div class="text-box">
              <div class="label">医疗险</div>
              <div class="value">未保障</div>
            </div>
            <div class="icon" />
          </div>
        </div>
        <div class="center-box">
          <div class="title">保障程度</div>
          <div class="num">已有保障1份</div>
          <div class="add">添加保险</div>
        </div>
        <div class="right-box">
          <div class="insurance-item" :class="'active'">
            <div class="icon" />
            <div class="text-box">
              <div class="label">意外险</div>
              <div class="value">保障一份</div>
            </div>
          </div>
          <div class="insurance-item">
            <div class="icon" />
            <div class="text-box">
              <div class="label">其他险</div>
              <div class="value">未保障</div>
            </div>
          </div>
        </div>
      </el-card>
    </div>
    <div class="bottom-box">
      <el-card class="card insurance-recommend">
        <div class="card-title">保险推荐</div>
        <div class="content-box">
          <div class="nav-box">
            <div class="type-box">
              <div class="type-item" :class="insuranceType_active==item.label&&'active'"
                v-for="item in insuranceTypeList" @click="selectInsuranceType(item)">
                {{ item.label }}
              </div>
            </div>
            <div class="search-box">
              <el-input v-model="searchForm.name" placeholder="搜索" suffix-icon="el-icon-search" />
            </div>
          </div>
          <div class="result-box">
            <div class="insurance-item" v-for="item in insuranceListData">
              <div class="base-info">
                <div class="img-box"></div>
                <div class="text-box">
                  <div class="name">{{ item.insurance_name }}</div>
                  <div class="tip"></div>
                  <div class="price">{{ item.insured_amount }} 元起</div>
                </div>
              </div>
              <div class="more-info">
                <div class="info-item">
                  <div class="value">{{ item.protection_amount }}万</div>
                  <div class="label">保额</div>
                </div>
                <div class="info-item">
                  <div class="value">{{ item.coverage }}</div>
                  <div class="label">保障范围</div>
                </div>
                <div class="info-item">
                  <div class="value">{{ item.guarantee_object }}</div>
                  <div class="label">保障对象</div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import * as api from './api.js';

export default {
  name: 'InsuranceAgent',
  data() {
    return {
      step1Form: {
        ageSegment: '35岁及以下',
        cityName: '广州市',
        positionLevel: '一级',
        businessTrip: '是',
        criticalIllness: '是',
        purchaseHospitalInsurance: '是',
        atPost: '是',
        backgroundDisease: '是',
      },
      insuranceTypeList: [{ label: '推荐' }, { label: '住院' }, { label: '意外' }, { label: '医疗' }],
      insuranceType_active: '推荐',
      searchForm: { name: '' },
      insuranceListData: [],
    };
  },
  created() {
    this.getInsuranceList();
  },
  methods: {
    getInsuranceList() {
      api.getList(this.step1Form).then((res) => {
        this.insuranceListData = [...res.rows];
      });
    },
    selectInsuranceType(item) {
      this.insuranceType_active = item.label;
    },
  },
};
</script>

<style lang="scss" scoped>
.container {
  padding: 20px;
  background-color: #f7f8fa;
  min-height: calc(100vh - 84px);
  font-family: 'Alibaba PuHuiTi 3.0';
  color: #3d3d3d;
  // display: flex;
  // flex-direction: column;
}

::v-deep .card {
  border-radius: 29px;
  .el-card__body {
    padding: 0;
    height: 100%;
    width: 100%;
  }
}

.top-box {
  // flex: 1;
  height: 350px;
  display: flex;
}
.card {
  &.my-info {
    flex: 1.8;

    .banner-box {
      width: 100%;
      height: 65%;
      padding-top: 22px;
      color: #fff;
      background-color: #79d4f7;
      background-image: url('./img/my-info-banner.png');
      background-repeat: no-repeat;
      background-position-x: right;
      background-size: auto 100%;
      display: flex;
      .red {
        color: #ff5252;
      }
      .title-box {
        margin: 0 40px;
        .title {
          font-size: 3rem;
          font-family: 'YouSheBiaoTiHei';
        }
        .tip {
          font-size: 1.5rem;
        }
      }
      .number-box {
        font-size: 1.125rem;
        .number1 {
          margin: 10px 0;
        }
        .number2 {
          display: flex;
          align-items: center;
          .icon {
            width: 24px;
            height: 24px;
            margin-right: 5px;
            background-image: url('./img/top-icon.png');
            background-repeat: no-repeat;
            background-size: 100% 100%;
          }
        }
      }
    }
    .info-box {
      width: 100%;
      height: 35%;
      padding: 20px 0;
      display: flex;
      .info-item {
        flex: 1;
        padding: 0 50px;
        border-right: 1px solid #d8d8d8;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: end;
        &:last-child {
          border: none;
        }
        &:first-child {
          position: relative;
          flex: 1.5;
          align-items: end;
        }
        .avatar {
          position: absolute;
          left: 100px;
          width: 150px;
          height: 150px;
          background-image: url('./img/avatar.png');
          background-repeat: no-repeat;
          background-size: 100% 100%;
        }
        .title {
          font-size: 2rem;
        }
        .link {
          font-size: 1.25rem;
          color: #9a9a9a;
        }
      }
    }
  }
  &.insurance-selected {
    flex: 1;
    margin-left: 20px;
    background-image: url('./img/insurance-selected-BG.png');
    background-repeat: no-repeat;
    background-size: 280px 280px;
    background-position: center;
    ::v-deep .el-card__body {
      display: flex;
    }
    .center-box {
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      margin: 0px 30px;

      .title {
        font-size: 20px;
        color: #b9b9b9;
      }
      .num {
        font-size: 20px;
      }
      .add {
        font-size: 16px;
        color: #b9b9b9;
      }
    }
    .left-box,
    .right-box {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      .insurance-item {
        display: flex;
        align-items: center;
        font-size: 20px;
        &.active {
          .value {
            color: #165dff;
          }
          .icon {
            background-image: url('./img/insurance-partial-icon.png');
          }
        }
        .value {
          color: #d6d6d6;
        }
        .icon {
          width: 60px;
          height: 60px;
          margin: 0 10px;
          background-image: url('./img/insurance-not-icon.png');
          background-repeat: no-repeat;
          background-size: 100% 100%;
        }
      }
    }
    .left-box {
      align-items: end;
    }
    .right-box {
      align-items: start;
    }
  }
}
.bottom-box {
  height: calc(100vh - 84px - 410px);
  margin-top: 20px;
  display: flex;
}

.card.insurance-recommend {
  flex: 1;
  ::v-deep .el-card__body {
    padding: 20px;
  }
  .card-title {
    flex-shrink: 0;
    font-size: 36px;
    margin-bottom: 20px;
  }
  .content-box {
    height: calc(100% - 70px);
    width: 100%;
    .nav-box {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      .type-box {
        display: flex;
        .type-item {
          font-size: 20px;
          border-radius: 32px;
          cursor: pointer;
          padding: 8px 20px;
          margin-right: 15px;
          &:last-child {
            margin-right: 0px;
          }
          &:hover {
            background-color: #f2f3f8;
          }
          &.active {
            background-color: #f2f3f8;
            color: #165dff;
          }
        }
      }
      .search-box {
        width: 25%;
        ::v-deep .el-input--medium {
          font-size: 16px;
          .el-input__inner {
            height: 40px;
            line-height: 40px;
            background-color: #f2f3f5;
            border: none;
          }
        }
      }
    }
    .result-box {
      height: calc(100% - 63.75px);
      width: 100%;
      overflow: auto;

      .insurance-item {
        display: inline-block;
        width: 24%;
        border-radius: 5px;
        border: 1px solid #e5e8ef;
        padding: 15px;
        margin-bottom: 20px;
        margin-right: 20px;
        &:nth-child(4n) {
          margin-right: 0px;
        }
        .base-info {
          display: flex;
          margin-bottom: 15px;
          .img-box {
            flex-shrink: 0;
            width: 120px;
            height: 120px;
            margin-right: 15px;
            background-image: url('./img/insurance-img.png');
            background-repeat: no-repeat;
            background-size: 100% 100%;
          }
          .text-box {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            .name {
              font-size: 22px;
            }
            .price {
              font-size: 22px;
              color: #ff0000;
            }
          }
        }
        .more-info {
          // flex: 1;
          display: flex;
          width: 100%;
          .info-item {
            flex: 1;
            text-align: center;
            font-size: 20px;
            border-right: 1px solid #d8d8d8;
            &:last-child {
              border: none;
            }
            .label {
              color: #c8c8c8;
            }
          }
        }
      }
    }
  }
}
</style>
